import request from "@/utils/request";

const TAG_BASE_URL = "/api/admin";

const TagAPI = {
  // 获取全部Tag
  getAllTag() {
    return request<any, any>({
      url: `${TAG_BASE_URL}/allTags`,
      method: "get",
    });
  },
  getTagsInfo({page, pageSize, tag_name, is_show}: QueryTag) {
    return request<any, TagPageData>({
      url: `${TAG_BASE_URL}/tagsList`,
      params: {page, pageSize, tag_name, is_show},
      method: "get",
    });
  },
  updateTag(tag: TagInfo) {
    return request<any, TagInfo>({
      url: `${TAG_BASE_URL}/tags`,
      method: "put",
      data: tag,
    });
  }
  ,
  createTag(tag: TagInfo) {
    return request<any, TagInfo>({
      url: `${TAG_BASE_URL}/tags`,
      method: "post",
      data: tag,
    });
  },
  delBatchTags(tag_ids: string) {
    return request<any, null>({
      url: `${TAG_BASE_URL}/deleteBatchTags`,
      method: "delete",
      data: {tag_ids}
    });
  },
  deleteTag(tagId: number | string) {
    return request<any, any>({
      url: `${TAG_BASE_URL}/tags`,
      params: {tag_id: tagId},
      method: "delete",
    });
  }
  ,

}

export default TagAPI

export interface QueryTag {
  page: number;
  pageSize: number;
  tag_name: string;
  is_show?: number | string;
}

export interface TagPageData {
  tags: TagInfo[];
  count: number;
}

export interface TagInfo {
  tag_id?: number;
  tag_name: string;
  is_show: number | boolean;
}

